package com.dg.contorller;

import java.util.List;

import javax.annotation.Resource;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.dg.core.controller.BaseController;
import com.dg.pojo.Dept;
import com.dg.service.DeptService;


@RequestMapping("/system")
@RestController
public class SystemController extends BaseController {

    @RequestMapping("/login")
    public String login() {
        pd = this.getParamsData();
        System.out.println("name: " + pd.getString("username") + "pwd: " + pd.getString("password"));

        JSONObject json = new JSONObject();
        json.put("code", 200);
        json.put("msg", "success");
        json.put("data", "登录成功");

        return json.toString();
    }

    @RequestMapping("/getMenu")
    public JSONObject getMenu() {
        pd = this.getParamsData();

        StringBuilder menuData = new StringBuilder();
        menuData.append("[");
        menuData.append("{'name':'系统管理','url':'','parent_id':0,'childMenu':[{'name':'菜单管理','url':'system/menu','parent_id':1},{'name':'用户管理','url':'member-list.html','parent_id':1}]}");
        menuData.append(",");
        menuData.append("{'name':'彩票管理','url':'','parent_id':0,'childMenu':[{'name':'种类管理','url':'bootstrap-table.html','parent_id':1},{'name':'销售管理','url':'system/sale','parent_id':1}]}");
        menuData.append(",");
        menuData.append("{'name':'流水管理','url':'','parent_id':0,'childMenu':[{'name':'收入管理','url':'system/shouru','parent_id':1},{'name':'支出管理','url':'system/zhichu','parent_id':1}]}");
        menuData.append(",");
        menuData.append("{'name':'订单管理','url':'','parent_id':0,'childMenu':[{'name':'分类管理','url':'system/fenlei','parent_id':1},{'name':'订单列表','url':'system/order','parent_id':1}]}");
        menuData.append("]");
        System.out.println(menuData);
        JSONArray dataJson = JSONArray.parseArray(menuData.toString());

        JSONObject json = new JSONObject();
        json.put("code", 200);
        json.put("msg", "success");
        json.put("data", dataJson);
        System.out.println(json.toString());
        return json;
    }


}
